package com.crealth.db;

import java.util.List;
import com.crealth.manager.MybatisManager;
import com.crealth.model.TeamModel;

public class TeamDb {

	public static Integer insertTeam(TeamModel team) {
		Integer res = MybatisManager.teamMapper.insertTeam(team);
		MybatisManager.commit();
		
		return res;
	}
    
	public static List<TeamModel> selectAllTeam() {
		List<TeamModel> teamls = MybatisManager.teamMapper.selectAllTeam();
		
		return teamls;
	}
	
	public static TeamModel selectTeamByID(int teamID) {
		TeamModel team = MybatisManager.teamMapper.selectTeamByID(teamID);
		
		return team;
	}
	
	public static List<TeamModel> selectCompanyTeam(int companyID) {
		List<TeamModel> teamls = MybatisManager.teamMapper.selectCompanyTeam(companyID);
		
		return teamls;
	}
	
	public static Integer updateTeamInfo(TeamModel team) {
		if (team == null) {
			return null;
		}
		Integer res = MybatisManager.teamMapper.updateTeamInfo(team);
		MybatisManager.commit();
		
		return res;
	}
	// 删除  大于 teamID 的团队
	public static Integer deleteTeamByGTTeamID(int teamID) {
		Integer res = MybatisManager.teamMapper.deleteTeamByGTTeamID(teamID);
		MybatisManager.commit();
		
		return res;
	}
	
	public static Integer deleteTeamByTeamID(int teamID) {
		Integer res = MybatisManager.teamMapper.deleteTeamByTeamID(teamID);
		MybatisManager.commit();
		
		return res;
	}
	
	public static Integer updateMonthPlanByTeamID(int teamID, int monthPlan) {
		Integer res = MybatisManager.teamMapper.updateMonthPlanByTeamID(teamID, monthPlan);
		MybatisManager.commit();
		
		return res;
	}
	
	public static Integer updateWeekPlanByTeamID(int teamID, int weekPlan) {
		Integer res = MybatisManager.teamMapper.updateWeekPlanByTeamID(teamID, weekPlan);
		MybatisManager.commit();
		
		return res;
	}
	
	public static Integer updateTeamLeaderByTeamID(int teamID, int teamLeaderID) {
		Integer res = MybatisManager.teamMapper.updateTeamLeaderByTeamID(teamID, teamLeaderID);
		MybatisManager.commit();
		
		return res;
	}
	
}
